﻿/*
* Activity Tracking Log v0.1.1 - http://activitytrackinglog.codeplex.com
* Activity Tracking Log for ASP.Net & ASP.Net MVC
* Copyright (c) 2011 Vadim Burac
* Licensed under the Microsoft Public License (Ms-PL)
* http://activitytrackinglog.codeplex.com/license
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ActivityTrackingLog.Storage;
using ActivityTrackingLog.Configuration;

namespace ActivityTrackingLog
{
    internal static class Factory
    {
        #region data

        private static ILogRepository _repository = null;

        #endregion

        #region ctors

        static Factory()
        {
            // storage
            Type storageImplementationType = Type.GetType(Config.Storage.Type);
            _repository = CreateInstance<ILogRepository>(storageImplementationType);
        }

        #endregion

        public static ILogRepository LogRepository
        {
            get
            {
                return _repository;
            }
        }

        #region helpers

        private static T CreateInstance<T>(Type t)
        {
            return (T)Activator.CreateInstance(t);
        }

        #endregion
    }
}
